#pragma once
#include <vector>
#include <string>

struct Section {
	char name[20];
	int index;
};

struct Entry {
	char name[20];
	int sectionIndex;
	int size;
	int offset;
};

class BinTextReader {

typedef std::vector<Section> Sections;
typedef std::vector<Entry> Entries;

public:
	BinTextReader(void);
	~BinTextReader(void);
	void readFile(const char* fileName);
	void saveBinary(const char* fileName);
	void readBinary(const char* fileName);
	bool contains(const char* name) const;
	int size() const {
		return m_Sections.size();
	}
	Section& getSection(int index) {
		return m_Sections[index];
	}
	Section& getSection(const char* name);
	Entry& getEntry(const char* name,int sectionIndex = -1);

	float getFloat(const char* name,int sectionIndex = -1);
	void getString(const char* name,char* buffer,int sectionIndex = -1);
	std::string getString(const char* name,int sectionIndex = -1);
private:
	int saveData(const std::string& value);
	int saveString(const std::string& value);
	int determineSize(const std::string& line);
	Sections m_Sections;
	Entries m_Entries;
	Entry m_Empty;
	float* m_Array;
	int m_Offset;
};

